<extend name="Public/common"/>
<block name="body">
    <style>
        a {
            text-decoration: none;
            out-line: none;
            color: #000000;
        }
    </style>
    <div class="wrapper wrapper-content animated fadeInRight">
        <div class="row">
            <div class="col-sm-12">
                <div class="ibox float-e-margins">
                    <div class="ibox-title">
                        <h5>
                            订单列表
                        </h5>
                        <h5 style="float: right;"><a href="javascript:location.reload();"><i class="fa fa-refresh"></i></a>
                        </h5>
                    </div>
                    <form class="navbar-form navbar-left" role="search" action="{:U('order/order_list')}" method="post">
                        <div class="form-group">
                            <input class="form-control" type="text" name="o_n" value="{$o_n}" style="width: 300px;"
                                   placeholder="请输入订单编号或用户名查找"/>
                        </div>
                        <button type="submit" class="btn btn-default" style="margin-top: 6px;">搜索</button>
                    </form>
                    <div class="ibox-content">
                        <div class="table-responsive">
                            <table class="table table-striped">
                                <thead>
                                <tr>
                                    <th></th>
                                    <th>订单编号</th>
                                    <th>订单类型</th>
                                    <th>订单折扣后实际支付价格</th>
                                    <th>用户</th>
                                    <th>商品</th>
                                    <th>收货地址</th>
                                    <th>商品件数</th>
                                    <th>状态</th>
                                    <th>操作</th>
                                </tr>
                                </thead>
                                <tbody>
                                <volist name="order_list" id="order_list">
                                    <tr>
                                        <td></td>
                                        <td>{$order_list.order_sn}</td>
                                        <td>{$order_list.order_types}</td>
                                        <td>{$order_list.payment_prices}</td>
                                        <td>{$order_list.user_ids}</td>
                                        <td>{$order_list.goods_names}</td>
                                        <td>{$order_list.address_ids|display_name}</td>
                                        <td>{$order_list.goods_nums}</td>
                                        <td>
                                            <switch name="order_list.order_state">
                                                <case value="0">处理中</case>
                                                <case value="1"><span style="color: green;">已完成</span></case>
                                            </switch>
                                        </td>
                                        <td>
                                            <switch name="order_list.order_state">
                                                <case value="0">
                                                    <a href='javascript:;' onclick="abandon({$order_list['order_id']})">
                                                        <button type="button" class="btn btn-outline btn-danger btn-xs">
                                                            放弃
                                                        </button>
                                                    </a>
                                                    <a href='javascript:;' onclick="achieve({$order_list['order_id']})">
                                                        <button type="button"
                                                                class="btn btn-outline btn-default btn-xs">完成
                                                        </button>
                                                    </a>
                                                </case>
                                            </switch>
                                        </td>
                                    </tr>
                                </volist>
                                </tbody>
                            </table>
                        </div>
                        <div style="text-align: center;" class="page">{$page}</div>
                    </div>
                </div>
            </div>
            <script>
                function achieve(e) {
                    $.ajax({
                        url: "{:U('order/achieve')}",
                        data: 'id=' + e,
                        type: 'post',
                        async: false,
                        dataType: 'json',
                        success: function (i) {
                            layer.msg(i.info)
                            setTimeout(window.history.go(0), 1000)
                        }
                    })
                }

                function abandon(e) {
                    $.ajax({
                        url: "{:U('order/abandon')}",
                        data: 'id=' + e,
                        type: 'post',
                        async: false,
                        dataType: 'json',
                        success: function (i) {
                            layer.msg(i.info)
                            setTimeout(window.history.go(0), 1000)
                        }
                    })
                }
            </script>
        </div>
    </div>
    <script src="__JS__/http/ajax.js"></script>

</block>